class Banner < ActiveRecord::Base
  has_attached_file :photo, :url => "/:attachment/:class/:style_:id.:extension",
    :path => ":rails_root/public/:attachment/:class/:style_:id.:extension", :default_url => "/images/default/banner.jpg"
  validates_attachment_presence :photo, :message  => I18n.t("errors.messages.attachment.presence")
  validates_attachment_size :photo, :less_than => 50.kilobytes, :message => I18n.t("errors.messages.attachment.size"), :allow_nil => true
  validates_attachment_content_type :photo, :content_type => ['image/jpeg'], :message => I18n.t("errors.messages.attachment.content_type"), :allow_nil => true
  validates :name, :length => {:within => 3..30}
  validates :href, :length => {:within => 3..700}
  validates :text, :length => {:within => 3..150}
  validates_inclusion_of :position, :in => %w[right left top]
  validates_inclusion_of :status, :in => %w[banned approved] 
end
